package miiteen.customsportal.Api;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import miiteen.core.result.ResultMessage;
import miiteen.core.result.ResultMessageTool;
import miiteen.customsportal.basic.beans.BasicOverview;
import miiteen.customsportal.basic.service.BasicOverviewService;
import org.apache.shiro.crypto.hash.Hash;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 兰州概况
 *
 */
@Api(tags = "兰州概况")
@RestController
@RequestMapping("/Api/basicOverview")
@CrossOrigin
public class BasicOverviewApiController {

    @Autowired
    private BasicOverviewService basicOverviewService;

    @GetMapping("findOverView")
    @ApiOperation("获取兰关概况或者光荣榜")
    public ResultMessage GetList(@ApiParam(name = "type", value = "类型 1:兰关概况 2：光荣榜")@RequestParam String type){
        Map<String, Object> map=new HashMap<>();
        map.put("type",type);
        List<BasicOverview> list=basicOverviewService.findListByMap(map);
        BasicOverview result=list.get(0);
        if(list!=null && list.size()>0){
            return ResultMessageTool.Success("success",result);
        }
        return ResultMessageTool.Error("未找到相关信息！");
    }

    @GetMapping("findById")
    @ApiOperation("详情页面")
    public ResultMessage GetOne(@ApiParam(name = "id", value = "该条数据的id")@RequestParam String id){
        if(id!=null){
            BasicOverview basicOverview=basicOverviewService.findById(Long.valueOf(id));
            if(basicOverview!=null){
                return ResultMessageTool.Success("success",basicOverview);
            }
            return ResultMessageTool.Error("未找到相关！");
        }
        return ResultMessageTool.Error("未获取到参数！");
    }


}
